
(function ( $ ) {
    $.fn.togglePassword = function( options ) {
        var s = $.extend( $.fn.togglePassword.defaults, options ),
        input = $( this );

        $( s.el ).bind( s.ev, function() {
            "password" == $( input ).attr( "type" ) ?
                $( input ).attr( "type", "text" ) :
                $( input ).attr( "type", "password" );
        });
    };

    $.fn.togglePassword.defaults = {
        ev: "click"
    };
}( jQuery ));

$ (function () {
    var close = document.getElementById("togglePassword");
    var open = document.getElementById("open");
    var span_class = $("#open").attr("class");
    var i = 1;
    close.onclick=function () {
        if ((i%2)== 1){
            $("#open").removeClass(span_class).addClass("glyphicon glyphicon-eye-open");
            i++;
        }
        else {
            $("#open").removeClass(span_class).addClass("glyphicon glyphicon-eye-close");
            i++;
        }
    }
});

//显示隐藏密码
$(function(){
    $('#password').togglePassword({
        el: '#togglePassword'
    });
});


